package com.ruoyi.common.config;

import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class OssConfig implements InitializingBean {
    @Value("${aliyun.oss.file.endpoint}")
    private String endpoint;
    @Value("${aliyun.access.keyid}")
    private String keyId;
    @Value("${aliyun.access.keysecret}")
    private String keySecret;
    @Value("${aliyun.oss.file.bucketname}")
    private String bucketName;
    @Value("${aliyun.oss.file.filenamePrefix}")
    private String filenamePrefix;
    @Value("${aliyun.oss.file.cdn}")
    private String cdn;
    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;
    public static String FILENAME_PREFIX;
    public static String CDN;



    public void afterPropertiesSet() {
        END_POINT = StringUtils.getStrOrDefault(this.endpoint,"");
        ACCESS_KEY_ID = StringUtils.getStrOrDefault(this.keyId,"");
        ACCESS_KEY_SECRET = StringUtils.getStrOrDefault(this.keySecret,"");
        BUCKET_NAME = StringUtils.getStrOrDefault(this.bucketName,"");
        FILENAME_PREFIX = StringUtils.getStrOrDefault(this.filenamePrefix,"");
        CDN = StringUtils.getStrOrDefault(this.cdn,"");
    }
}
